package bank
{
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	import utils.DisplayTool;
	import utils.ColorTool;
	
	public class ChestBoard extends Sprite
	{
		public static const TYPE_SMALL:int = 0;
		public static const TYPE_BIG:int = 1;
		
		private var bgSmall:Bitmap;
		private var bgBig:Bitmap;
		private var text:TextField;
		
		public function ChestBoard()
		{
			this.mouseChildren = false;
			this.mouseEnabled = false;
			initBg();
			initText();
		}
		
		private function initText():void
		{
			text = new TextField();
			
			var tf:TextFormat = new TextFormat();
			tf.color = 0xFFFFFF;
			tf.size = 12;
			text.y = - 2;
			text.selectable = false;
			text.defaultTextFormat = tf;
			text.height = 20;
			text.width = bgSmall.width;
			addChild(text);
		}
		
		private function initBg():void
		{
			bgSmall = new Bitmap(ChestTool.smallBoard.bitmapData);
			bgBig = new Bitmap(ChestTool.bigBoard.bitmapData);	
		}
		
		public function update(state:int,level:String):void
		{
			DisplayTool.removeAllChild(this);
			ColorTool.saturation(bgSmall);
			ColorTool.saturation(bgBig);
			switch (state)
			{
				case ChestTool.CHEST_STATE_INVALID:
					addChild(bgSmall);
					addChild(text);
					text.text = "需" + level + "级";
					ChestTool.blackBoard(bgSmall);
					break;
				case ChestTool.CHEST_STATE_ACTIVATE:
					addChild(bgBig);
					addChild(text);
					text.text = "可激活";
					//ChestTool.blueBoard(bgBig);
					break;
				case ChestTool.CHEST_STATE_EMPTY:
					addChild(bgSmall);
					addChild(text);
					text.text = "可储存";
					break;
				case ChestTool.CHEST_STATE_HAVEST:
					addChild(bgSmall);
					addChild(text);
					text.text = "可收获";
					break;
				case ChestTool.CHEST_STATE_STORE:
					addChild(bgSmall);
					addChild(text);
					text.text = "存储中";
					break;
			}
		}
	}
}